package tuanda.soict.firstsun.AbilityPackage;

import java.util.ArrayList;
import java.util.Random;

import tuanda.soict.firstsun.EffectPackage.Effect;
import tuanda.soict.firstsun.LogicPackage.Army;
import tuanda.soict.firstsun.LogicPackage.Coordinate;
import tuanda.soict.firstsun.LogicPackage.Scenario;

/**
 * @author tuanda_soict_hut
 * @version 0.0.1
 * @since 9-9-2012
 */
public class FirstAid_Ability extends Ability {

	public FirstAid_Ability(int id, String name, int range, int area, int affect) {
		super(id, name, range, area, affect);
	}

	@Override
	public void mainAct(Army army, Scenario scenario) {
		int level = getAbilityLevel();

		ArrayList<Effect> effects = army.getEffectList();
		Effect temp;
		for (int i = 0; i < effects.size(); i++) {
			temp = effects.get(i);
			if (temp.getEffectPoint() < 0) {
				army.removeEffectAtIndex(i);
			}
			i--;
		}

		army.setHealth(army.getHealth() + 5 + (new Random()).nextInt(5) + level);

		army.setExperience(
				army.getExperience() + (level + 10) * army.getRank(),
				armyManager);
		army.setActionLeft(false);
	}

	@Override
	public void calculation(Army army, Scenario scenario) {
		this.setAbilityPoint(getAbilityLevel() * army.getRank());
	}

	@Override
	public ArrayList<Coordinate> calculateAffectedArea(Army army,
			Scenario scenario) {
		ArrayList<Coordinate> temp = new ArrayList<Coordinate>();
		temp.add(new Coordinate(army.getLocationX(), army.getLocationY()));
		return temp;
	}
}
